package Radiostation_POJOS;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;


/**
 *
 * @author George
 */


@Entity
@Table(name = "PLAYLIST_SONGS")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PlaylistSongs.findAll", query = "SELECT p FROM PlaylistSongs p"),
    @NamedQuery(name = "PlaylistSongs.findBySongIdAndPlaylist", query = "SELECT p FROM PlaylistSongs p where p.playlist=:playlist and p.song.songId=:song"),
    @NamedQuery(name = "PlaylistSongs.findById", query = "SELECT p FROM PlaylistSongs p WHERE p.id = :id")})
public class PlaylistSongs implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Integer id;
    @JoinColumn(name = "PLAYLIST", referencedColumnName = "PLAYLIST_ID")
    @ManyToOne(optional = false)
    private Playlist playlist;
    @JoinColumn(name = "SONG", referencedColumnName = "SONG_ID")
    @ManyToOne(optional = false)
    private Song song;

    public PlaylistSongs() {
    }

    public PlaylistSongs(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Playlist getPlaylist() {
        return playlist;
    }

    public void setPlaylist(Playlist playlist) {
        this.playlist = playlist;
    }

    public Song getSong() {
        return song;
    }

    public void setSong(Song song) {
        this.song = song;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PlaylistSongs)) {
            return false;
        }
        PlaylistSongs other = (PlaylistSongs) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Radiostation_POJOS.PlaylistSongs[ id=" + id + " ]";
    }
    
}
